package com.jobs.producer0.demo;

import com.jobs.common.factory.RabbitMqUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

public class ReceiveLogsDirect02 {

    public static final String EXCHANGE_NAME = "direct_logs";

    public static final String QUEUE_NAME = "disk";

    public static void main(String[] args) throws Exception {

        Channel channel = RabbitMqUtils.getChannel();

        //声明一个队列
        channel.queueDeclare(QUEUE_NAME,true,false,false,null);

        //绑定交换机与队列
        channel.queueBind(QUEUE_NAME, EXCHANGE_NAME,"error");


        DeliverCallback deliverCallback = (consumerTag, message) -> {
            System.out.println("ReceiveLogsDirect02控制台打印接受到的消息：" + new String(message.getBody()));
        };

        channel.basicConsume(QUEUE_NAME,true,deliverCallback,consumerTag -> {});
    }
}

